File: src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\AsyncSymbolVisitor`1.cs
Web Access
Project: src\src\CodeStyle\Core\CodeFixes\Microsoft.CodeAnalysis.CodeStyle.Fixes.csproj (Microsoft.CodeAnalysis.CodeStyle.Fixes)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
 
using System.Threading.Tasks;
using Roslyn.Utilities;
 
namespace Microsoft.CodeAnalysis;
 
internal abstract class AsyncSymbolVisitor<TResult> : SymbolVisitor<ValueTask<TResult>>
{
    protected abstract TResult DefaultResult { get; }
 
    public override ValueTask<TResult> Visit(ISymbol? symbol)
        => symbol?.Accept(this) ?? ValueTaskFactory.FromResult(DefaultResult);
 
    public override ValueTask<TResult> DefaultVisit(ISymbol symbol)
        => ValueTaskFactory.FromResult(DefaultResult);
}